<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- 引入公共meta -->
<jsp:include page="/static/iframe/import/_meta.jsp"></jsp:include>
<title>取派员添加</title>
<link rel="stylesheet" href="static/iframe/bootstrap/css/bootstrap.min.css"/>
<link rel="stylesheet" href="static/iframe/bootstrap/css/bootstrap-theme.min.css">
<%-- <jsp:include page="/static/iframe/import/_header.jsp"></jsp:include> --%>
<style type="text/css">
.input-margin-bottom {
	margin-bottom: 10px;
}
</style>
</head>
<body>
	<div class="container" style="margin-top:10px;">
		<div class="container-fluid">
			<form class="form-horizontal" id="staff_add">
				<div class="row">
				  <div class="col-sm-4 col-md-4 col-lg-3 input-margin-bottom form-group">
						<div class="input-group">
							<span class="input-group-addon">*&nbsp;姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名:</span>
							<input type="text" class="form-control" placeholder="姓名"
									name="staffName" id="name"/>
						</div>
					</div>
					
					<div class="col-sm-4 col-md-4 col-lg-3 input-margin-bottom form-group">
						<div class="input-group">
							<span class="input-group-addon">*&nbsp;号&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;码:</span>
					<input type="text" class="form-control" placeholder="号码"
									name="telephone" id="telephone"/>
						</div>
					</div>
				
				
					<div class="col-sm-4 col-md-4 col-lg-3 input-margin-bottom form-group">
						<div class="input-group input-group-md">
							<span class="input-group-addon">
								<span class="c-red">*&nbsp;</span>&nbsp;P&nbsp;&nbsp;&nbsp;&nbsp;D&nbsp;&nbsp;&nbsp;&nbsp;F:</span>
							<select class="form-control" name="haspda" id="haspdaid">
									<option selected="selected" value="">请选择</option>
									<option value="1">有</option>
									<option value="0">无</option>
								</select>
						</div>
					</div>
					
					<div
						class="col-sm-4 col-md-4 col-lg-3 input-margin-bottom form-group">
						<div class="input-group input-group-md">
							<span class="input-group-addon"><span class="c-red">*&nbsp;</span>&nbsp;标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;识:</span>
							<select class="form-control" name="deltag" id="deltagid">
									<option selected="selected" value="">请选择</option>
									<option value="1">已删除</option>
									<option value="0">未删除</option>
								</select>
						</div>
					</div>
					
					<div
						class="col-sm-4 col-md-4 col-lg-3 input-margin-bottom form-group">
						<div class="input-group input-group-md">
							<span class="input-group-addon"><span class="c-red">*&nbsp;</span>&nbsp;单&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;位:</span>
							<select class="form-control" name="organizationId" id="organization">
									<option selected="selected" value="">请选择</option>
									<c:forEach items="${organizations}" var="org">
										<option value="${org.id}">${org.organizationName}</option>
									</c:forEach>
								</select>
						</div>
					</div>
					
					<div class="col-sm-4 col-md-4 col-lg-3 input-margin-bottom form-group">
						<div class="input-group">
							<span class="input-group-addon">*&nbsp;&nbsp;取派标准:&nbsp;</span>
							<textarea class="form-control" placeholder="取派标准" rows="4" name="standard" id="standard"></textarea>
						</div>
					</div>
				</div>
				<div class="text-center mt-15" style="display:block;">
					<div class="tooltip-demo">
						<button class="btn btn-primary" type="submit" >
							<i class="glyphicon glyphicon-ok"></i>&nbsp;提交
						</button>
						&nbsp;
						<button class="btn btn-success" type="reset">
							<i class="glyphicon glyphicon-refresh" id="reset"></i>&nbsp;重置
						</button>
						&nbsp; <a class="btn btn-default" href="javascript:layer_close()"
							target="_blank"><i class="glyphicon glyphicon-share-alt"></i>&nbsp;返回</a>
					</div>
				</div>
			</form>
		</div>
	</div>
<jsp:include page="/static/iframe/import/_footer.jsp"></jsp:include>
<script type="text/javascript" src="static/plugins/window/layershow.js"></script>
<script type="text/javascript" src="static/plugins/window/referparent.js"></script>
<!-- <script type="text/javascript" src="static/plugins/jq/jquery-3.2.1.js"></script> -->
<script type="text/javascript" src="static/iframe/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="static/iframe/bootstrap/js/bootstrapValidator.min.js"></script>
<!--[if lt IE 10]>
    <script type="text/javascript" src="static/plugins/input-placeholder/ieplaceholder.js"></script>
<![endif]-->
<script type="text/javascript">
$(function() {
 	/* $.ajax({
		type : "post",
		url : "staff/getOrganization",
		dataType : "json",
		success : function(res) {
			for (var i = 0; i < res.length; i++) {
				alert(res[i].id);
				alert(res[i].organizationName);
				$("#organization").append(
						"<option values='"+res[i].id+"'>"
								+ res[i].organizationName + "</option>");
			}
		}
	}); */
	/*表单验证*/
	$("#staff_add").bootstrapValidator({
		message : 'This value is not valid',
		feedbackIcons : {
			valid : 'glyphicon glyphicon-ok',
			invalid : 'glyphicon glyphicon-remove',
			validating : 'glyphicon glyphicon-refresh'
		},
		fields : {
			 staffName : {
				message : '姓名验证失败',
				validators : {
					regexp : {
						regexp : /^[\u4e00-\u9fa5]{0,}$/,
						message : '姓名只能包含中文'
					},
					notEmpty : {
						message : '姓名不能为空'
					}
				}
			},
			telephone : {
				validators : {
					notEmpty : {
						message : '号码不能为空'
					},
					regexp : {
						regexp : /^0?(13[0-9]|15[012356789]|17[013678]|18[0-9]|14[57])[0-9]{8}$/,
						message : '号码格式错误'
					}
				}
			},
			standard : {
				validators : {
					notEmpty : {
						message : '取派员标准不能为空'
					},
					regexp : {
						regexp : /^[\u4e00-\u9fa5]{0,}$/,
						message : '真实姓名只能包含中文'
					}
				}
			} 
		}
	//做ajax请求用到
	}).on('success.form.bv',function(e) {
	 			e.preventDefault();
				var $form = $(e.target); //拿到form表单
				//请求修改角色
				$.ajax({
					type : "post",
					url : "staff/add",
					dataType : "json",
					data : $form.serialize(),
					success : function(result) {
						if (result.flag) {
							layer.msg("添加成功！", {
								icon : 1,
								time : 1000
							});
							setTimeout(referParent, 1000);
						} else {
							layer.msg(result.msg, {
								icon : 2,
								time : 1000
							});
							$("#staff_add").data('bootstrapValidator').resetForm();
						}
					}
				});
				
			});
	 
	//清空表单数据和状态
	$("#reset").on("click", function() {
		$("#staff_add").data('bootstrapValidator').resetForm();
	});
	
});


</script>
</body>
</html>